//
//  MSRangeView.m
//  JYG_Agent
//
//  Created by apple on 15/10/21.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "MSRangeView.h"
#import "MSRangeSlider.h"
@interface MSRangeView ()
@property(nonatomic,strong)UIProgressView *progressView;
@property(nonatomic,strong)MSRangeSlider *rangeSlider;
@end

@implementation MSRangeView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self initUI];
    }
    return self;
}

-(id)init
{
    self=[super init];
    if (self)
    {
        [self initUI];
    }
    return self;
}

-(void)initUI
{
    int x=15,y=10;
    CGRect rect=CGRectMake(x, y, APPFRAME.size.width-2*x, 20);
    UILabel* titleLabel=[[UILabel alloc] initWithFrame:rect];
    titleLabel.tag=101;
    titleLabel.font=[UIFont fontWithName:@"STHeitiSC-Light" size:16];
    titleLabel.textColor = kDarkGrayColor;
    [self addSubview:titleLabel];
    
    self.rangeSlider = [[MSRangeSlider alloc] initWithFrame:CGRectMake(15, titleLabel.bottom+20, APPFRAME.size.width-30, 50)];
    [self addSubview:self.rangeSlider];
    self.height = self.rangeSlider.bottom + 10;
}

- (void)resetRange
{
    self.rangeSlider.leftValue = self.minValue;
    self.rangeSlider.rightValue = self.maxValue;
}

-(void)setTitle:(NSString *)title
{
    _title=title;
    UILabel* titleLabel=(UILabel*)[self viewWithTag:101];
    [titleLabel setText:title];
}

-(void)setAttributeTitle:(NSAttributedString *)attributeTitle
{
    _attributeTitle=attributeTitle;
    UILabel* titleLabel=(UILabel*)[self viewWithTag:101];
    titleLabel.attributedText = attributeTitle;
}

- (void)setMinValue:(CGFloat)minValue
{
    _minValue = minValue;
    self.rangeSlider.minValue = minValue;
}

- (void)setMaxValue:(CGFloat)maxValue
{
    _maxValue = maxValue;
    self.rangeSlider.maxValue = maxValue;
}

- (CGFloat)leftValue
{
    return self.rangeSlider.leftValue;
}

- (CGFloat)rightValue
{
    return self.rangeSlider.rightValue;
}

@end
